package com.jihui.feign;

/**
 * ${DESCRIPTION}
 *
 * @author 王进
 * @since 2017-08-23 09:51
 **/

import com.jihui.feign.enterprise.EnterpriseHystrix;
import feign.Request;
import feign.Retryer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableFeignClients(basePackages = {"com.jihui.feign.enterprise"})
public class EnterpriseAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean(EnterpriseHystrix.class)
    public EnterpriseHystrix accountManagerFeignClientFallback() {
        return new EnterpriseHystrix();
    }

    @Bean
    Request.Options feignOptions() {
        return new Request.Options(/**connectTimeoutMillis**/1 * 1000, /** readTimeoutMillis **/1 * 1000);
    }

    @Bean
    Retryer feignRetryer() {
        return Retryer.NEVER_RETRY;
    }
}
